<%--
  Created by IntelliJ IDEA.
  User: asus
  Date: 2018/3/10
  Time: 14:14
  To change this template use File | Settings | File Templates.
--%>
<%@page pageEncoding="UTF-8" %>
<!doctype html>
<html lang="zh-cmn">
<head>
    <%@include file="/WEB-INF/jsp/comm/head.jsp"%>
</head>
<body>
<div class="container">
    <table id="conTb"
    data-toggle="table"
    data-url="sys/config/search"
    data-striped="true">
        <thead>
            <tr>
                <th data-field="configCode">配置编号</th>
                <th data-field="configName">配置名称</th>
                <th data-field="configValueName">参数</th>
                <th data-field="isStart" data-formatter="formStatus">是否启用</th>
                <th data-events="events" data-formatter="fmtOpt">操作</th>
            </tr>
        </thead>
    </table>
</div>

<div class="container" style="margin-top: 20px;">
    <table class="table table-bordered table-striped" id="childer">
        <tr>
            <th>配置编号</th>
            <th>配置名称</th>
            <th>参数</th>
            <th>是否启用</th>
            <th>操作</th>
        </tr>
        <c:forEach items="${l}" var="l">
            <tr>
                <td name="a">${l.configCode}</td>
                <td>${l.configName}</td>
                <td name="b">${l.configValueName}</td>
                <td name="c">${l.isStart}</td>
                <td><button class="btn btn-danger" onclick="update(this)">修改状态</button></td>
            </tr>
        </c:forEach>
    </table>
</div>

<%@include file="/WEB-INF/jsp/comm/foot.jsp"%>
<script>
    function update(wo){
        var code=$(wo).parent().parent().find('[name=a]').html();
        var valueName=$(wo).parent().parent().find('[name=b]').html();
        var start=$(wo).parent().parent().find('[name=c]').html();
        var isStart;
        if(start=="0"){
            start="1";
        }else{
            start="0";
        }
        $.post(ctx+"sys/config/updateStatus",{isStart:start,configCode:code,valueName:valueName},function (msg) {
            if(msg==1){
                toastr.success("修改成功")
            }else{
                toastr.warning("修改失败")
            }
            location.reload()
        })
    }
    function formStatus(value,row){
        return value == 1 ? "启用" : "停用";
    }
    function fmtOpt(row) {
        var search='<button class="btn btn-default search">查看</button>';
        return search;
    }
    var events={
        "click .search":function (e, value, row) {
            search(row);
        }
    }
    function search(row){
        var url="sys/get/getBy?configCode="+row["configCode"];
        location.href=url;
    }
</script>
</body>
</html>
